//矿池 数字
var total = getBonusPool(),//1000
    profit = (total * 0.8501).toFixed(2),
    gold = (total * 0.0999).toFixed(2),
    popular = (total * 0.05).toFixed(2);
// 分享生成的内容
var str = 'http://www.3m3d.vip/market.html'
//倒计时 
function countDown(date, target) {

    var setTime = new Date(date).getTime(),
        timer = null;
    ~function core() {
        var nowTime = new Date().getTime(),
            leftTime = 0,
            d = 0,
            h = 0,
            m = 0,
            s = 0;
        leftTime = Math.ceil((setTime - nowTime) / 1000);
        if (nowTime <= setTime) {
            d = ~~(leftTime / 86400);
            h = ~~(leftTime % 86400 / 3600);
            m = checkTime(~~(leftTime % 86400 % 3600 / 60));
            s = checkTime(~~(leftTime % 86400 % 3600 % 60));
            timer = setTimeout(core, 1e3);
            target.innerHTML = h + ' : ' + m + ' : ' + s;
        } else {
            clearTimeout(timer);
            timer = null;
            target.innerHTML = '已结束';
        }
    }()

}

//回到顶部
 function scrolltop(){
	 $(document).scrollTop(0)
 }

//将0-9的数字前面加上0
function checkTime(i) {
    if (i < 10) {
        i = "0" + i;
    }
    return i;
}

function add0(m) { return m < 10 ? '0' + m : m }
//时间戳转化成时间格式
function timeFormat(timestamp) {
    //timestamp是整数，否则要parseInt转换,不会出现少个0的情况
    var time = new Date(timestamp * 1000);
    var year = time.getFullYear();
    var month = time.getMonth() + 1;
    var date = time.getDate();
    var hours = time.getHours();
    var minutes = time.getMinutes();
    var seconds = time.getSeconds();
    return year + '/' + add0(month) + '/' + add0(date) + ' ' + add0(hours) + ':' + add0(minutes) + ':' + add0(seconds);
}

// 获取矿池数
function getBonusPool() {
	
    var bonusPool = "";
    $.ajax({ url: "http://43.229.36.44:8081/getBonusPool", async: false, dataType: "html", success: function (data) { bonusPool = data; } });
    return bonusPool;

}

//获取倒计时时间 
function getGameEndDate(){
	
	var gameEndDate = "";
	$.ajax({ url: "http://43.229.36.44:8081/getGameEndDate", async: false, dataType: "html", success: function (data) { gameEndDate = data; } });
	return gameEndDate;
 
}

//获取用户名 
function getLastestBidder(){
	
	var userName = "";
	$.ajax({ url: "http://43.229.36.44:8081/getLastestBidder", async: false, dataType: "html", success: function (data) { userName = data; } });
	return userName;
 
}
//获取用户名 
function getLastestBid(){
	
	var usernumber = "";
	$.ajax({ url: "http://43.229.36.44:8081/getLastestBid", async: false, dataType: "html", success: function (data) { usernumber = data; } });
	return usernumber;
 
}